package cn.lanqiao.web.config;

import cn.lanqiao.web.interceptors.AdminLoginInterceptor;
import cn.lanqiao.web.interceptors.UserLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private AdminLoginInterceptor adminLoginInterceptor ;
    //@Autowired
    //private UserLoginInterceptor userLoginInterceptor;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/file/**").addResourceLocations("file:E:/lanqiao/images");

    }
/*    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(adminLoginInterceptor)
                .addPathPatterns("/**")
                .order(1)
                .excludePathPatterns("/admin/login",
                                     "/admin/captcha",
                                     "/admin/getCode",
                                     "/user/login",
                                     "/user/getCode",
                                     "/user/getUserById",
                                     "/user/updateUserById",
                                     "/user/userRegister",
                                     "/captchaImage"
                );

        registry.addInterceptor(userLoginInterceptor)
                .addPathPatterns("/**")
                .order(2)
                .excludePathPatterns("/user/login",
                                     "/login.html",
                                     "/user/captcha",
                                     "/user/getCode",
                                     "/captchaImage"
                );
    }*/
}
